'use strict'

$(function () {
    List()
})

function List(basadate) {
    getBlogList().then(data=>{
        if (basadate) {
            data = basadate
        }
        $('#tbData').rmove()
        let html = `
        <tr class="row">
            <td>${item.title}</td>
            <td>${item.digest}</td>
            <td>${item.content}</td>
            <td>${item.author}</td>
            <td>${item.creaeTime}</td>
            <td>
                <input type="button" value="修改" onclick="update(${item.id})">
                <input type="button" value="删除" onclick="del(${item.id})">
            </td>
        </tr>
    `
        data.append(html)
    })
}

function query() {
    let keyword = $('#keyword').val()
    getBlogById().then(data=>{

    })

}

function del(id) {
    if (confirm('确认删除？')) {
        delBlogById().then(data => {
            window.location.href = './index.html'
        })
    }
}

function add(){
    window.location.href = './addOrEdit.html'
}

function save(){
    window.location.href = './index.html'
}
function cancel(){
    window.location.href = './index.html'
}